package com.ruoyi.system.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SpffNotificationsMapper;
import com.ruoyi.system.domain.SpffNotifications;
import com.ruoyi.system.service.ISpffNotificationsService;

/**
 * 通知Service业务层处理
 * 
 * @author xjj
 * @date 2025-09-11
 */
@Service
public class SpffNotificationsServiceImpl implements ISpffNotificationsService 
{
    @Autowired
    private SpffNotificationsMapper spffNotificationsMapper;

    /**
     * 查询通知
     * 
     * @param id 通知主键
     * @return 通知
     */
    @Override
    public SpffNotifications selectSpffNotificationsById(Long id)
    {
        return spffNotificationsMapper.selectSpffNotificationsById(id);
    }

    /**
     * 查询通知列表
     * 
     * @param spffNotifications 通知
     * @return 通知
     */
    @Override
    public List<SpffNotifications> selectSpffNotificationsList(SpffNotifications spffNotifications)
    {
        return spffNotificationsMapper.selectSpffNotificationsList(spffNotifications);
    }

    /**
     * 新增通知
     * 
     * @param spffNotifications 通知
     * @return 结果
     */
    @Override
    public int insertSpffNotifications(SpffNotifications spffNotifications)
    {
        return spffNotificationsMapper.insertSpffNotifications(spffNotifications);
    }

    /**
     * 修改通知
     * 
     * @param spffNotifications 通知
     * @return 结果
     */
    @Override
    public int updateSpffNotifications(SpffNotifications spffNotifications)
    {
        return spffNotificationsMapper.updateSpffNotifications(spffNotifications);
    }

    /**
     * 批量删除通知
     * 
     * @param ids 需要删除的通知主键
     * @return 结果
     */
    @Override
    public int deleteSpffNotificationsByIds(Long[] ids)
    {
        return spffNotificationsMapper.deleteSpffNotificationsByIds(ids);
    }

    /**
     * 删除通知信息
     * 
     * @param id 通知主键
     * @return 结果
     */
    @Override
    public int deleteSpffNotificationsById(Long id)
    {
        return spffNotificationsMapper.deleteSpffNotificationsById(id);
    }

    /**
     * 标记指定通知为已读
     * 
     * @param ids 通知ID数组
     * @return 结果
     */
    @Override
    public int markAsReadByIds(Long[] ids)
    {
        return spffNotificationsMapper.markAsReadByIds(ids);
    }

    /**
     * 标记用户所有未读通知为已读
     * 
     * @param userId 用户ID
     * @return 结果
     */
    @Override
    public int markAllAsReadByUserId(Long userId)
    {
        return spffNotificationsMapper.markAllAsReadByUserId(userId);
    }

    /**
     * 获取用户未读通知数量
     * 
     * @param spffNotifications 通知查询对象
     * @return 未读数量
     */
    @Override
    public int selectSpffNotificationsUnreadCount(SpffNotifications spffNotifications){
        return spffNotificationsMapper.getUnreadCount(spffNotifications.getUserId(), spffNotifications.getType());
    }

    /**
     * 按类型获取用户未读通知数量
     * 
     * @param userId 用户ID
     * @param type 通知类型
     * @return 未读数量
     */
    @Override
    public int selectSpffNotificationsUnreadCountByType(Long userId, Integer type){
        return spffNotificationsMapper.getUnreadCount(userId, type);
    }

    /**
     * 查询用户的互动类型通知列表（点赞、评论、关注、收藏）
     * 
     * @param userId 用户ID
     * @return 通知集合
     */
    @Override
    public List<SpffNotifications> selectInteractionNotificationsList(Long userId){
        return spffNotificationsMapper.selectInteractionNotificationsList(userId);
    }

}
